package com.atguigu.day20.syn01.exer.e1;

//todo 窗口线程

public class       WindowThread extends Thread{
    //todo 静态成员变量 被所有对象共享
  static   int tickets = 200;

    @Override
    public void run() {
        while (true){
            synchronized ("AA") {
                if (tickets <= 0) {
                    break;
                }
                tickets--;
                try {
                    Thread.sleep(20);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(getName() + "卖了一张票,还有[" + tickets + "]张票");
            }
        }

    }
}
